class Solution {
public:
    void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
        int p = 0, q = 0;
        vector<int> temp;
        while (p < m || q < n) {
            if (q >= n ||(p < m && nums1[p] < nums2[q])) {
                temp.push_back(nums1[p++]);
            } else {
                temp.push_back(nums2[q++]);
            }
        }
        nums1.clear();
        nums1 = move(temp);
    }
};
